Skip to main content

Block Statements

Block statements are the basic building blocks of Pebble code.
They control variable bindings, runtime assertions, failure modes, and debugging.

Variable and Constant Declarations

Pebble supports both mutable (let) and immutable (const) bindings.

const threshold = 100;
let counter = tx.inputs.length();
  • const values cannot be reassigned

  • let values can be mutated (though mutation in Pebble compiles into SSA-style assignments internally)

Assert

assert checks a condition at runtime. If it fails, the transaction is invalid.

assert userOutput.value.amountOf(policy, tokenName) >= minReceiveAmount;

Assertions are the primary way to enforce validator rules in Pebble.

Fail

fail immediately aborts execution with an error.

fail "Insufficient token balance";

Useful when explicit error reporting is preferable to silent assertion failures.

Trace

trace allows debug logging during simulation. (Traces are generally stripped or limited in on-chain execution.)

trace("Processing order...");
trace(userOutput.address);

This is especially helpful for off-chain testing to understand contract flow.